<template>
  <div class="userInfo">
    <el-tabs class="DF-el_tabs">
      <el-tab-pane label="基本信息">
        <el-col :span="18">
          <el-form :model="form" label-width="100px" :rules="dataRule">
            <el-form-item label="账户">
              <el-input v-model="form.userName" readonly />
            </el-form-item>
            <el-form-item label="用户名" prop="trueName">
              <el-input v-model="form.trueName"  />
            </el-form-item>
            <el-form-item label="手机号" prop="phone" >
              <el-input v-model="form.phone"   prop="phone" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="dataFormSubmit()">保 存</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>

import { UpdateUser } from '@/api/user/userSetting'
import { mapGetters } from 'vuex'
export default {
  props: {
    user: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      form: {

      },
      dataRule: {
        phone: [
          { required: true, message: '请输入手机号码', trigger: 'blur' },
          { validator: this.formValidate('iphone', '手机号码格式不正确'), trigger: 'blur' }
        ],
        trueName: [
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ]
      },
    }
  },
  computed: {
    creatorTime() {
      return this.df.toDate(this.form.creatorTime)
    },
    entryDate() {
      return this.df.toDate(this.form.entryDate)
    },
    prevLogTime() {
      return this.df.toDate(this.form.prevLogTime)
    },
    ...mapGetters(['userInfo'])
  },
  created() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      this.form = this.userInfo
    },
    dataFormSubmit() {
      UpdateUser(this.form).then(res => {
        this.$message({
          message: res.msg,
          type: 'success',
          duration: 1500
        })
        this.$store.commit('user/SET_USERINFO', this.form)
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.userInfo {
  height: 100%;
  overflow: hidden;
  >>> .el-tabs__nav-scroll {
    padding-top: 0 !important;
  }
}
</style>
